** Folder indicating where the files are located **
cd "C:\Users\remij\Desktop\Main Regressions"
set more off

* This do-file generates all the tables and some figures. 
* They are generated in the same folder as the data.

**********************************************
*** MANUAL PROGRAM THAT MUST BE RUN BEFORE ***
**********************************************

* this program generates a coefficient and standard error (with stars) 
* to report on a linear combination:
program drop _all
program proglincom, rclass
    lincom `0'
    local coefftxttmp = string(r(estimate),"%9.3f")
    local se = r(se)
    return local setxt = "["+string(`se',"%9.3f")+"]"
    local tstat=r(estimate)/r(se)
    gen pval = tprob(r(df), abs(`tstat'))*100
    egen pvalcat = cut(pval), at(0,1,5,10,100)
    lab def starlab 0 "***" 1 "**" 5 "*" 10 "", replace
    lab val pvalcat starlab
    decode pvalcat, gen(stars)
	local startxt = stars
	return local coefftxt = "`coefftxttmp'" + "`startxt'"
	drop pval pvalcat stars
end 
* this program generates a coefficient and standard error (with stars) 
* to report on a non-linear combination:
program prognlcom, rclass
    nlcom `0'
    matrix A = r(b)
	local coefftxttmp = string(A[1,1],"%9.3f")
	matrix B = r(V)
    local se = sqrt(B[1,1])
    return local setxt = "["+string(`se',"%9.3f")+"]"
    local tstat=A[1,1]/`se'
    gen pval = tprob(r(df_r), abs(`tstat'))*100
    egen pvalcat = cut(pval), at(0,1,5,10,100)
    lab def starlab 0 "***" 1 "**" 5 "*" 10 "", replace
    lab val pvalcat starlab
    decode pvalcat, gen(stars)
	local startxt = stars
	return local coefftxt = "`coefftxttmp'" + "`startxt'"
	display "`coefftxttmp'"
	drop pval pvalcat stars
	matrix drop A B
end 

***************
*** TABLE 1 ***
***************

use jjm_jebo_21, clear
keep if year == 1932

** Summary stats for web appx table B1 **
sum cens_chri_2000 cens_prot_2000 cens_cath_2000 dhs_presbyterian_mean dhs_methodist_mean 
sum ldist2mission ldist2firstpresb ldist2firstmetho ldist2firstcathonavr ldist2mission_prot ldist2mission_cath ldist2mission_presb ldist2mission_metho

** TABLE 1 **
capture erase table1.xls
capture erase table1.txt
capture erase table1.tex
foreach Z in 40 {
local missionvars "ldist2mission_prot ldist2mission_cath ldist2firstpresb ldist2firstmetho ldist2firstcathonavr"
foreach X of varlist cens_prot_2000 cens_cath_2000 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' `missionvars', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `missionvars' using table1.xls, keep(`missionvars') addtext(lights, `X', controls, no, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' `missionvars' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `missionvars' using table1.xls, keep(`missionvars') addtext(lights, `X', controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
local missionvars "ldist2mission_presb ldist2mission_metho ldist2mission_cath ldist2firstpresb ldist2firstmetho ldist2firstcathonavr"
foreach X of varlist dhs_presbyterian_mean dhs_methodist_mean {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' `missionvars', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `missionvars' using table1.xls, keep(`missionvars') addtext(lights, `X', controls, no, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' `missionvars' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `missionvars' using table1.xls, keep(`missionvars') addtext(lights, `X', controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

***************
*** TABLE 2 ***
***************

use jjm_jebo_21, clear
keep if year == 1932

** Web summary stats for web appx table B1 **
sum lnltc2000 cens_chri_2000 cens_prot_2000 cens_cath_2000 dhs_presbyterian_mean dhs_methodist_mean dhs_catholic_mean

** TABLE 2 **
capture erase table2.xls
capture erase table2.txt
capture erase table2.tex
foreach Z in 40 {
local religsh "cens_prot_2000 cens_cath_2000"
foreach X of varlist lnltc2000 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' `religsh', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, no, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom cens_prot_2000 - cens_cath_2000
acreg `X' `religsh' `stdctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, standard, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom cens_prot_2000 - cens_cath_2000
acreg `X' `religsh' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom cens_prot_2000 - cens_cath_2000
acreg `X' `religsh' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom cens_prot_2000 - cens_cath_2000
}
local religsh "dhs_presbyterian_mean dhs_methodist_mean dhs_catholic_mean"
foreach X of varlist lnltc2000 {
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' `religsh', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, no, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom dhs_presbyterian_mean - dhs_methodist_mean 
lincom dhs_presbyterian_mean - dhs_catholic_mean
acreg `X' `religsh' `stdctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, standard, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom dhs_presbyterian_mean - dhs_methodist_mean 
lincom dhs_presbyterian_mean - dhs_catholic_mean
acreg `X' `religsh' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom dhs_presbyterian_mean - dhs_methodist_mean 
lincom dhs_presbyterian_mean - dhs_catholic_mean
acreg `X' `religsh' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table2.xls, keep(`religsh') addtext(lights, `X', controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom dhs_presbyterian_mean - dhs_methodist_mean 
lincom dhs_presbyterian_mean - dhs_catholic_mean
}
}

***************
*** TABLE 3 ***
***************

use jjm_jebo_21, clear
keep if year == 1932

** Summary stats for web appx table B1 **
sum urate2000 cogn_br lit_all childmort1549 cens_chri_2000 cens_prot_2000 cens_cath_2000 dhs_presbyterian_mean dhs_methodist_mean dhs_catholic_mean

** TABLE 3 **
capture erase table3.xls
capture erase table3.txt
capture erase table3.tex
foreach Z in 40 {
foreach X of varlist urate2000 cogn_br lit_all childmort1549 {
local religsh "cens_prot_2000 cens_cath_2000"
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' `religsh', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table3.xls, keep(`religsh') addtext(lights, `X', controls, no, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' `religsh' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table3.xls, keep(`religsh') addtext(lights, `X', controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach X of varlist urate2000 cogn_br lit_all childmort1549 {
local religsh "dhs_presbyterian_mean dhs_methodist_mean dhs_catholic_mean"
local stdctrls "soil5 dist2riv_navigable10 ln_export_area prec_mean dist2coast histo_malaria city1800 density1800m"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' `religsh', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table3.xls, keep(`religsh') addtext(lights, `X', controls, no, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `X' `religsh' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 `religsh' using table3.xls, keep(`religsh') addtext(lights, `X', controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom dhs_presbyterian_mean - dhs_methodist_mean
}
}

*************************************************
*** STRATEGY: DISTANCE TO PROTESTANT BOUNDARY ***
*************************************************
*** TABLE 4 *************************************
*** TABLE 8 PANEL A *****************************
*** TABLE 9 PANEL A *****************************
*** TABLE 11 COLS 1-3 ***************************
*** WEB APPX TABLE B3 COLS 1-6 ******************
*** WEB APPX TABLE B4 COLS 1-3 ******************
*** WEB APPX TABLE B5 COLS 1-3 ******************
*** WEB APPX TABLE B7-B8 COLS 1-3 ***************
*** WEB APPX TABLE B9 COLS 1-3 ******************
*************************************************

use jjm_jebo_21, clear
keep if year == 1932
replace urate2000 = urate2000 / 100

** Summary stats for web appx table B1 **
sum lnltc2000 cens_prot_2000 ldist2segment sphere1867 ldist2sphere_strline

** TABLE 4A **
* PANEL A*
capture erase table4A.xls
capture erase table4A.txt
capture erase table4A.tex
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* 1-2
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' ldist2segment `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment using table4A.xls, keep(ldist2segment) addtext(test, IV, controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
acreg `X' ldist2segment `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment using table4A.xls, keep(ldist2segment) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* 3-4
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' ldist2segment `basectrls' `ourctrls1900' if sphere1867 == 0, latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment using table4A.xls, keep(ldist2segment) addtext(test, IVnosphere, controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
acreg `X' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0, latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment using table4A.xls, keep(ldist2segment) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* 5-6
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `X' ldist2sphere_strline `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using table4A.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
acreg `X' ldist2sphere_strline `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using table4A.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
* PANEL B *
capture erase table4B.xls
capture erase table4B.txt
capture erase table4B.tex
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* 1-2
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 ldist2segment `basectrls' `ourctrls1900' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using table4B.xls, keep(ldist2segment ) addtext(test, IV, controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
acreg lnltc2000 ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using table4B.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* 3-4
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 ldist2segment `basectrls' `ourctrls1900' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using table4B.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
acreg lnltc2000 ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using table4B.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* 5-6
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 ldist2sphere_strline `basectrls' `ourctrls1900'  if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using table4B.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours1900, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
acreg lnltc2000 ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using table4B.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}

** TABLE 8 PANEL A **
capture erase table8A.xls
capture erase table8A.txt
capture erase table8A.tex
foreach Z in 40 {
foreach X of varlist maxprot_yn ldist2mission_prot {
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 (`X' = ldist2segment) `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 lnltc2000 using table8A.xls, keep(`X') addstat(F-statistic, e(widstat)) addtext(conley, `Z', test, IV, controls, ours1900) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 (`X' = ldist2segment) `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 lnltc2000 using table8A.xls, keep(`X') addstat(F-statistic, e(widstat)) addtext(conley, `Z', test, IV, controls, ours) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** TABLE 9 PANEL A **
capture erase table9A.xls
capture erase table9A.txt
capture erase table9A.tex
foreach C in 40 {
foreach Z of varlist urate1931 education_cap1545_1931 infirm_cap1545_1931 {
foreach X of varlist cens_prot_2000 {
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls_nopop "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' ldist2segment `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 ldist2segment using table9A.xls, keep(ldist2segment) addtext(test, RF, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' ldist2segment `basectrls' `ourctrls_nopop', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 ldist2segment using table9A.xls, keep(ldist2segment) addtext(test, RF, controls, ours1931nopop, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** TABLE 11 COLS 1-3 **
capture erase table11_cols_1_3.xls
capture erase table11_cols_1_3.txt
capture erase table11_cols_1_3.tex
foreach O of varlist lit_all childmort1549 {
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using table11_cols_1_3.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* DROPPING SPHERES *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using table11_cols_1_3.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* DIST TO STRAIGHT BOUNDARY AS IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using table11_cols_1_3.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}

** WEB APPX TABLE B3 COLS 1-6 **
capture erase tableB3_cols_1_6.xls
capture erase tableB3_cols_1_6.txt
capture erase tableB3_cols_1_6.tex
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 ldist2segment `basectrls' `ourctrls' i.`R' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB3_cols_1_6.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
}
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 ldist2segment `basectrls' `ourctrls' i.`R' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB3_cols_1_6.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 ldist2sphere_strline `basectrls' `ourctrls' i.`R' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using tableB3_cols_1_6.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}

** WEB APPX TABLE B4 COLS 1-3 **
capture erase tableB4_cols_1_3.xls
capture erase tableB4_cols_1_3.txt
capture erase tableB4_cols_1_3.tex
foreach L of numlist 2011 {
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB4_cols_1_3.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB4_cols_1_3.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using tableB4_cols_1_3.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}

** WEB APPX TABLE B5 COLS 1-3 **
capture erase tableB5_cols_1_3.xls
capture erase tableB5_cols_1_3.txt
capture erase tableB5_cols_1_3.tex
foreach O of varlist urate2000 cogn_br {
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB5_cols_1_3.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* DROPPING SPHERES *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB5_cols_1_3.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* DIST TO STRAIGHT BOUNDARY AS IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using tableB5_cols_1_3.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}

*** WEB APPX TABLE B7-B8 COLS 1-3 ***
* We first create the weights *
sum urate2000
replace urate2000 = urate2000*100
sum urate2000
gen invwt = 100-urate2000
capture erase tableB7B8_cols_1_3.xls
capture erase tableB7B8_cols_1_3.txt
capture erase tableB7B8_cols_1_3.tex
** FIRST OUTCOME WITH WEIGHTS **
foreach O of varlist lnltc2000 {
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB7B8_cols_1_3.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* DROPPING SPHERES *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB7B8_cols_1_3.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* DIST TO STRAIGHT BOUNDARY AS IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using tableB7B8_cols_1_3.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}
** LAST THREE OUTCOMES **
foreach O of varlist impboth_rural lit_agri childmort1549_rural  {
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB7B8_cols_1_3.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* DROPPING SPHERES *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB7B8_cols_1_3.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* DIST TO STRAIGHT BOUNDARY AS IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using tableB7B8_cols_1_3.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}

** WEB APPX TABLE B9 COLS 1-3 **
* We create the two outcomes *
gen lit_all_prof = lit_all_f/lit_all_m
gen childmort1549_prof = childmort1549_f/childmort1549_m
capture erase tableB9_cols_1_3.xls
capture erase tableB9_cols_1_3.txt
capture erase tableB9_cols_1_3.tex
foreach O of varlist lit_all_prof childmort1549_prof {
foreach X of varlist cens_prot_2000 {
foreach Z in 40 {
* IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB9_cols_1_3.xls, keep(ldist2segment ) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
* DROPPING SPHERES *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment `basectrls' `ourctrls' if sphere1867 == 0  & cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment  using tableB9_cols_1_3.xls, keep(ldist2segment ) addtext(test, IVnosphere, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
* DIST TO STRAIGHT BOUNDARY AS IV *
local basectrls "ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2sphere_strline `basectrls' `ourctrls' if cens_prot_2000 != ., latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2sphere_strline using tableB9_cols_1_3.xls, keep(ldist2sphere_strline) addtext(test, IVstraight, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel 
}
}
}

***************
*** TABLE 5 ***
***************

* Summary of identification strategies

************************************
* STRATEGY: SPHERES/STRAIGHT LINES *
*** TABLE 6 ************************
*** TABLE 8 PANELS B-C *************
*** TABLE 9 PANELS B-C *************
*** TABLE 11 COLS 4-7 **************
*** WEB APPX TABLE B3 COLS 7-14 **** 
*** WEB APPX TABLE B4 COLS 4-7 *****
*** WEB APPX TABLE B5 COLS 4-7 *****
*** WEB APPX TABLES B7-B8 COLS 4-7 *
*** WEB APPX TABLE B9 COLS 4-7 *****
************************************

use jjm_jebo_21, clear
keep if year == 1932
drop if methopresb1847 == 1

** Summary stats for web appx table B1 **
sum lnltc2000 pres_meth_dhs presby1867 method1867 east_of_bound sphere1867 east_of_strline

** TABLE 6 **
* PANEL A 
capture erase table6A.xls
capture erase table6A.txt
capture erase table6A.tex
foreach C in 40 {
* 1-2 
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' `exogvar' `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours1890, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' `exogvar' `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
* 3-4
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' `exogvar' `basectrls'  `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, westbound, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' `exogvar' `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
* 5-6
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' `exogvar' `basectrls'  `ourctrls1900' if sphere1867  == 0, latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0, latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
* 7-8
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' `exogvar' `basectrls'  `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' `exogvar' `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6A.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
* PANEL B *
capture erase table6B.xls
capture erase table6B.txt
capture erase table6B.tex
foreach C in 40 {
* 1-2 
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 `exogvar' `basectrls' `ourctrls1900' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours1890, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom presby1867 - method1867
acreg lnltc2000 `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
lincom presby1867 - method1867
}
* 3-4
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 `exogvar' `basectrls'  `ourctrls1900' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, westbound, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
* 5-6
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 `exogvar' `basectrls'  `ourctrls1900' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
* 7-8
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 `exogvar' `basectrls'  `ourctrls1900' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table6B.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** TABLE 8 PANELS B-C **
capture erase table8BC.xls
capture erase table8BC.txt
capture erase table8BC.tex
foreach C in 40 {
foreach Z of varlist pres_meth_mis pres_meth_dist {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 (`Z' = `exogvar') `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `Z' using table8BC.xls, keep(`Z') addstat(F-statistic, e(widstat)) addtext(IV, spheredum, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 (`Z' = `exogvar') `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `Z' using table8BC.xls, keep(`Z') addstat(F-statistic, e(widstat)) addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
foreach C in 40 {
foreach Z of varlist pres_meth_mis pres_meth_dist {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 (`Z' = `exogvar') `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `Z' using table8BC.xls, keep(`Z') addstat(F-statistic, e(widstat)) addtext(IV, westbound, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 (`Z' = `exogvar') `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `Z' using table8BC.xls, keep(`Z') addstat(F-statistic, e(widstat)) addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** TABLE 9 PANELS B-C **
capture erase table9BC.xls
capture erase table9BC.txt
capture erase table9BC.tex
foreach C in  40 {
local lincomset "presby1867 - method1867"
foreach Z of varlist urate1931 education_cap1545_1931 infirm_cap1545_1931 {
foreach X of varlist cens_prot_2000 {
local basectrls "longitude longitude2 longitude3 longitude4 latitude latitude2 latitude3 latitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls_nopop "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' presby1867 method1867 `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
proglincom "`lincomset'"
outreg2 presby1867 method1867 using table9BC.xls, keep(presby1867 method1867) addtext(presb-metho, `r(coefftxt)', se, `r(setxt)', test, RF, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' presby1867 method1867 `basectrls' `ourctrls_nopop', latitude(latitude) longitude(longitude) dist(`C') spatial
proglincom "`lincomset'"
outreg2 presby1867 method1867 using table9BC.xls, keep(presby1867 method1867) addtext(presb-metho, `r(coefftxt)', se, `r(setxt)', test, RF, controls, ours1931nopop, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
foreach C in 40 {
foreach Z of varlist urate1931 education_cap1545_1931 infirm_cap1545_1931 {
foreach X of varlist cens_prot_2000 {
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls_nopop "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' east_of_bound `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 east_of_bound using table9BC.xls, keep(east_of_bound) addtext(test, RF, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' east_of_bound `basectrls' `ourctrls_nopop', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 east_of_bound using table9BC.xls, keep(east_of_bound) addtext(test, RF, controls, ours1931nopop, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** TABLE 11 COLS 4-7 **
capture erase table11_cols_4_7.xls
capture erase table11_cols_4_7.txt
capture erase table11_cols_4_7.tex
foreach O of varlist lit_all childmort1549 {
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table11_cols_4_7.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table11_cols_4_7.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table11_cols_4_7.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table11_cols_4_7.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B3 COLS 7-14 **
capture erase tableB3_cols_7_14.xls
capture erase tableB3_cols_7_14.txt
capture erase tableB3_cols_7_14.tex
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 `exogvar' `basectrls' `ourctrls' i.`R' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_cols_7_14.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 `exogvar' `basectrls' `ourctrls' i.`R' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_cols_7_14.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 `exogvar' `basectrls' `ourctrls' i.`R' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_cols_7_14.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 `exogvar' `basectrls' `ourctrls' i.`R' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_cols_7_14.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B4 COLS 4-7 **
capture erase tableB4_cols_4_7.xls
capture erase tableB4_cols_4_7.txt
capture erase tableB4_cols_4_7.tex
foreach L in 2011 {
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB4_cols_4_7.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB4_cols_4_7.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB4_cols_4_7.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB4_cols_4_7.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B5 COLS 4-7 **
replace urate2000 = urate2000 / 100
capture erase tableB5_cols_4_7.xls
capture erase tableB5_cols_4_7.txt
capture erase tableB5_cols_4_7.tex
foreach O of varlist urate2000 cogn_br {
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB5_cols_4_7.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB5_cols_4_7.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB5_cols_4_7.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB5_cols_4_7.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

*** WEB APPX TABLE B7-B8 COLS 4-7 ***
* We first create the weights *
sum urate2000
replace urate2000 = urate2000*100
sum urate2000
gen invwt = 100-urate2000
capture erase tableB7B8_cols_4_7.xls
capture erase tableB7B8_cols_4_7.txt
capture erase tableB7B8_cols_4_7.tex
** FIRST OUTCOME WITH WEIGHTS **
foreach O of varlist lnltc2000 {
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
** LAST THREE OUTCOMES **
foreach O of varlist impboth_rural lit_agri childmort1549_rural  {
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_cols_4_7.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B9 COLS 4-7 **
* We create the two outcomes *
gen lit_all_prof = lit_all_f/lit_all_m
gen childmort1549_prof = childmort1549_f/childmort1549_m
capture erase tableB9_cols_4_7.xls
capture erase tableB9_cols_4_7.txt
capture erase tableB9_cols_4_7.tex
foreach O of varlist lit_all_prof childmort1549_prof {
foreach C in 40 {
foreach Z in pres_meth_dhs {
local exogvar "presby1867 method1867"
local basectrls "longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB9_cols_4_7.xls, keep(`exogvar') addtext(IV, spheredum, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB9_cols_4_7.xls, keep(`exogvar') addtext(IV, westbound, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_bound"
local basectrls "ldist2segment longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB9_cols_4_7.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
foreach Z in pres_meth_dhs {
local exogvar "east_of_strline"
local basectrls "ldist2sphere_strline longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' `exogvar' `basectrls' `ourctrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB9_cols_4_7.xls, keep(`exogvar') addtext(IV, west_straight, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

*********************************
* STRATEGY: BUFFER STRATEGY *****
*** TABLE 7 PART A **************
*** TABLE 8 PANEL D *************
*** TABLE 9 PANEL D *************
*** TABLE 11 COL 8 **************
*** WEB APPX TABLE B3 COL 15-16 *
*** WEB APPX TABLE B4 COL 8 *****
*** WEB APPX TABLE B5 COL 8 *****
*** WEB APPX TABLE B7-B8 COL 8 **
*** WEB APPX TABLE B9 COL 8 *****
*********************************


use jjm_jebo_21, clear
keep if year == 1932
drop if sphere_all == 1

** Summary stats for web appx table B1 **
sum lnltc2000 cens_cath_2000 proddistcore

** TABLE 7 PART A **
capture erase table7Acols12.xls
capture erase table7Acols12.txt
capture erase table7Acols12.tex
* First panel
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `Z' `exogvar' `basectrl' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Acols12.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg `Z' `exogvar' `basectrl' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Acols12.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
* Second panel
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc2000 `exogvar' `basectrl'  `ourctrls1900' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Acols12.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg lnltc2000 `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Acols12.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** TABLE 8 PANEL D **
capture erase table8D.xls
capture erase table8D.txt
capture erase table8D.tex
foreach C in 40 {
foreach Z of varlist maxcath_yn ldist2mission_cath {
local exogvar "proddistcore"
local basectrls "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg lnltc2000 (`Z' = `exogvar') `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `Z' using table8D.xls, keep(`Z') addstat(F-statistic, e(widstat)) addtext(IV, IV, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg lnltc2000 (`Z' = `exogvar') `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `Z' using table8D.xls, keep(`Z') addstat(F-statistic, e(widstat)) addtext(IV, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** TABLE 9 PANEL D **
capture erase table9D.xls
capture erase table9D.txt
capture erase table9D.tex
foreach C in 40 {
foreach Z of varlist urate1931 education_cap1545_1931 infirm_cap1545_1931 {
foreach X of varlist cens_prot_2000 {
local exogvar "proddistcore"
local basectrls "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls_nopop "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `Z' proddistcore `basectrls' `ourctrls1900', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 proddistcore using table9D.xls, keep(proddistcore) addtext(test, RF, controls, ours1900, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
acreg `Z' proddistcore `basectrls' `ourctrls_nopop', latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 proddistcore using table9D.xls, keep(proddistcore) addtext(test, RF, controls, ours1931nopop, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** TABLE 11 COL 8 **
capture erase table8_col_11.xls
capture erase table8_col_11.txt
capture erase table8_col_11.tex
foreach O of varlist lit_all childmort1549 {
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table8_col_11.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}

** WEB APPX TABLE B3 COLS 15-16 **
capture erase tableB3_col_15_16.xls
capture erase tableB3_col_15_16.txt
capture erase tableB3_col_15_16.tex
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
foreach R in region_4 province_2000 {
xi: acreg lnltc2000 `exogvar' `basectrl' `ourctrls' i.`R' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_col_15_16.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}

** WEB APPX TABLE B4 COL 8 **
capture erase tableB4_col_8.xls
capture erase tableB4_col_8.txt
capture erase tableB4_col_8.tex
foreach L in 2011 {
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' `exogvar' `basectrl' `ourctrls'  if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB4_col_8.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}

** WEB APPX TABLE B5 COL 8 **
replace urate2000 = urate2000 / 100
sum urate2000
capture erase tableB5_col_8.xls
capture erase tableB5_col_8.txt
capture erase tableB5_col_8.tex
foreach O of varlist urate2000 cogn_br {
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB5_col_8.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}

*** WEB APPX TABLE B7-B8 COL 8 ***
* We first create the weights *
sum urate2000
replace urate2000 = urate2000*100
sum urate2000
gen invwt = 100-urate2000
capture erase tableB7B8_col_8.xls
capture erase tableB7B8_col_8.txt
capture erase tableB7B8_col_8.tex
** FIRST OUTCOME WITH WEIGHTS **
foreach O of varlist lnltc2000 {
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_col_8.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}
** LAST THREE OUTCOMES **
foreach O of varlist impboth_rural lit_agri childmort1549_rural  {
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_col_8.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}

** WEB APPX TABLE B9 COLS 8 **
* We create the two outcomes *
gen lit_all_prof = lit_all_f/lit_all_m
gen childmort1549_prof = childmort1549_f/childmort1549_m
capture erase tableB9_col_8.xls
capture erase tableB9_col_8.txt
capture erase tableB9_col_8.tex
foreach O of varlist lit_all_prof childmort1549_prof {
foreach Z of varlist cens_cath_2000 {
foreach X in proddistcore {
foreach C in 40 {
local exogvar "`X'"
local basectrl "ldist2mission_cath1880 ldist2navrongo ldist2lome"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB9_col_8.xls, keep(`exogvar') addtext(test, IV, instru, `X', controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
}

***************************************
*** TABLE 7 PART B: JIRAPA STRATEGY ***
*** TABLE 11 COL 9 ********************
*** WEB APPX TABLE B3 COLS 17-18 ******
*** WEB APPX TABLE B4 COL 9 ***********
*** WEB APPX TABLE B5 COL 9 ***********
*** WEB APPX TABLE B7-B8 COL 9 ********
*** WEB APPX TABLE B9 COL 9 ***********
***************************************

use jjm_jebo_21, clear
keep if year == 1932

*** summary stats for web appx table B1 ***
sum ldist2jirapa 

** TABLE 7B COLS 3-4 **
capture erase table7Bcols34.xls
capture erase table7Bcols34.txt
capture erase table7Bcols34.tex
* First panel 
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg `Z' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Bcols34.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg `Z' `exogvar' `basectrl'  `ourctrls' i.region_4 if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Bcols34.xls, keep(`exogvar') addtext(test, IV, controls, ours_regFE, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
* Second panel
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc2000 `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Bcols34.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg lnltc2000 `exogvar' `basectrl'  `ourctrls' i.region_4 if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table7Bcols34.xls, keep(`exogvar') addtext(test, IV, controls, ours_regFE, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** TABLE 11 COL 9 **
capture erase table11_col_9.xls
capture erase table11_col_9.txt
capture erase table11_col_9.tex
foreach O of varlist lit_all childmort1549 {
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
* IV * 
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using table11_col_9.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B3 COLS 17-18 **
capture erase tableB3_col_17_18.xls
capture erase tableB3_col_17_18.txt
capture erase tableB3_col_17_18.tex
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc2000 `exogvar' `basectrl'  `ourctrls' i.region_4 if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_col_17_18.xls, keep(`exogvar') addtext(test, IV, controls, ours_regFE, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
xi: acreg lnltc2000 `exogvar' `basectrl'  `ourctrls' i.province_2000 if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB3_col_17_18.xls, keep(`exogvar') addtext(test, IV, controls, ours_regFE, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** WEB APPX TABLE B4 COL 9 **
capture erase tableB4_col_9.xls
capture erase tableB4_col_9.txt
capture erase tableB4_col_9.tex
foreach L in 2011 {
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
xi: acreg lnltc`L' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB4_col_9.xls, keep(`exogvar') addtext(test, IV, controls, ours_regFE, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B5 COL 9 **
replace urate2000 = urate2000/100
capture erase tableB5_col_9.xls
capture erase tableB5_col_9.txt
capture erase tableB5_col_9.tex
foreach O of varlist urate2000 cogn_br {
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
* IV * 
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB5_col_9.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

*** WEB APPX TABLE B7-B8 COL 9 ***
* We first create the weights *
sum urate2000
replace urate2000 = urate2000*100
sum urate2000
gen invwt = 100-urate2000
capture erase tableB7B8_col_9.xls
capture erase tableB7B8_col_9.txt
capture erase tableB7B8_col_9.tex
** FIRST OUTCOME WITH WEIGHTS **
foreach O of varlist lnltc2000 {
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
* IV * 
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_col_9.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}
** LAST THREE OUTCOMES **
foreach O of varlist impboth_rural lit_agri childmort1549_rural  {
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
* IV * 
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != . [pw=invwt], latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB7B8_col_9.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

** WEB APPX TABLE B9 COLS 9 **
* We create the two outcomes *
gen lit_all_prof = lit_all_f/lit_all_m
gen childmort1549_prof = childmort1549_f/childmort1549_m
capture erase tableB9_col_9.xls
capture erase tableB9_col_9.txt
capture erase tableB9_col_9.tex
foreach O of varlist lit_all_prof childmort1549_prof {
foreach C in 40 {
foreach Z of varlist cens_cath_2000 {
local exogvar "ldist2jirapa"
local basectrl "ldist2northborder catho_yn_1931 ldist2cath1931"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50 cocoa minet_dist1932_50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
* IV * 
xi: acreg `O' `exogvar' `basectrl'  `ourctrls' if cens_cath_2000 != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' using tableB9_col_9.xls, keep(`exogvar') addtext(test, IV, controls, ours, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}
}

***************************************
*** TABLE 10: PANEL CITY POPULATION ***
*** FIGURE 7: EVENT STUDY *************
***************************************

use jjm_jebo_21_panel, clear

*** summary stats for web appx table B1 ***
sum chgpop1k chgpop1k_extmarg chgpop1k_nomis lag1missions_yn lag2missions_yn lag1prot lag1presb

** TABLE 10 **
capture erase table10.xls
capture erase table10.txt
capture erase table10.tex
* 1) 
xi: acreg chgpop1k lag1missions_yn lag1lnewcitypop1k i.dist31yr i.year|lnewcitypop1k1891 i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
outreg2 lag1missions_yn using table10.xls, keep(lag1missions_yn) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 2) 
xi: acreg chgpop1k lag1missions_yn lag1lnewcitypop1k i.ethnicyr i.year|lnewcitypop1k1891 i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
outreg2 lag1missions_yn using table10.xls, keep(lag1missions_yn) addtext(test, ethnic-yr FE) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 3) 
local lincomset "lag1missions_yn + lag2missions_yn"
xi: acreg chgpop1k lag1missions_yn lag2missions_yn lag1lnewcitypop1k i.dist31yr i.year|lnewcitypop1k1891 i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
proglincom "`lincomset'"
outreg2 lag1missions_yn lag2missions_yn using table10.xls, keep(lag1missions_yn lag2missions_yn) addtext(test, secondlag, sum2lags, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 4) 
xi: acreg chgpop1k_extmarg lag1missions_yn i.dist31yr i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
outreg2 lag1missions_yn using table10.xls, keep(lag1missions_yn) addtext(test, extmargin)  br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 5) 
xi: acreg chgpop1k_nomis lag1missions_yn lag1lnewcitypop1k i.dist31yr i.year|lnewcitypop1k1891 i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
outreg2 lag1missions_yn using table10.xls, keep(lag1missions_yn) addtext(test, pureintmargin)  br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 6) 
local lincomset "lag1missions_yn + lag1prot"
xi: acreg chgpop1k lag1missions_yn lag1prot lag1lnewcitypop1k i.dist31yr i.year|lnewcitypop1k1891 i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
proglincom "`lincomset'"
outreg2 lag1missions_yn lag1prot using table10.xls, keep(lag1missions_yn lag1prot) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
* 7) 
xi: acreg chgpop1k lag1missions_yn lag1prot lag1presbmetho lag1lnewcitypop1k i.dist31yr i.year|lnewcitypop1k1891 i.gridcell if year >= 1891 & year <= 1931, latitude(latitude) longitude(longitude) dist(40) spatial
outreg2 lag1missions_yn lag1prot lag1presbmetho using table10.xls, keep(lag1missions_yn lag1prot lag1presbmetho) br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append

*************************
*** DATA FOR FIGURE 3 ***
*************************

use jjm_jebo_21, clear
keep if year == 1932
* We replace the census shares with the DHS shares if the census share is missing *
* Christian *
gen cens_chri_2000_v2 = cens_chri_2000
replace cens_chri_2000_v2 = dhs_christian_mean if cens_chri_2000 == .
* Protestant *
gen cens_prot_2000_v2 = cens_prot_2000
replace cens_prot_2000_v2 = dhs_protestant_mean if cens_prot_2000 == .
* Catholic *
gen cens_cath_2000_v2 = cens_cath_2000
replace cens_cath_2000_v2 = dhs_catholic_mean if cens_prot_2000 == .
* Islam *
gen cens_isla_2000_v2 = cens_isla_2000
replace cens_isla_2000_v2 = dhs_muslim_mean if cens_isla_2000 == .
* Trad *
gen cens_trad_2000_v2 = cens_trad_2000
replace cens_trad_2000_v2 = dhs_traditional_mean if cens_trad_2000 == .
foreach X of varlist cens_prot_2000_v2 cens_cath_2000_v2 dhs_presbyterian_mean dhs_methodist_mean cens_chri_2000_v2 cens_isla_2000_v2 cens_trad_2000_v2 {
replace `X' = 999 if `X' == .  
} 
keep gridcell cens_prot_2000_v2 cens_cath_2000_v2 dhs_presbyterian_mean dhs_methodist_mean cens_chri_2000_v2 cens_isla_2000_v2 cens_trad_2000_v2
sum *
export excel using "religion_shares_census_dhs_new.xls", firstrow(variables) replace
* The file was then imported in ArcGIS to create the maps of Figure 3.

****************
*** FIGURE 7 ***
****************

** REGRESSION RESULTS NEEDED FOR THE FIGURE  **

use jjm_jebo_21_panel, clear

* We first create a few more variables 
tab minyearopen, m
* years since opening *
gen yrsopen = year-minyearopen
tab yrsopen, m
gen post_0 = 0
replace post_0 = 1 if yrsopen == 0
foreach X of numlist 3(3)39 {
gen post_`X' = 0
replace post_`X' = 1 if (yrsopen == `X' | yrsopen == (`X'-1) | yrsopen == (`X'-2))
}
foreach X of numlist 3(3)9 {
gen pre_`X' = 0
replace pre_`X' = 1 if (yrsopen == -`X' | yrsopen == (-`X'+1) | yrsopen == (-`X'+2))
}

* The regression generating the coefficients * 
xi: areg chgpop1k pre_* post_* lag1lnewcitypop1k i.dist31yr i.year|lnewcitypop1k1891 if year >= 1891 & year <= 1931, robust absorb(gridcell) cluster(district_2000)
regsave pre_* post_* using eventstudy1k, replace pval level(95) ci

** FIGURE ** 

use eventstudy1k, clear
gen year = substr(var,-2,2)
replace year = subinstr(year, "_", "",.)
destring year, replace
gen pre = "pre" if _n <= 4
replace pre = "post" if _n > 4
replace year = -year if pre == "pre"
sort year
** DRAFT ** 
twoway (scatter coef year, mcolor(black) msize(medium) lcolor(black) lpattern(solid) lwidth(medthick)), xline(0) legend(off) ylabel(-1.5(0.5)1.5) ytitle(Effect on Log Urban Pop. (>= 1,000 Inh.)) xtitle(Year of Opening)
* We modify manually before exporting
graph use "Figure7.gph"
graph export Figure7.png, replace width(2620) height(1908)

***********************************************************************************************************

****************************
****************************
*** WEB APPENDIX RESULTS ***
****************************
****************************

*************************
*** WEB APPX TABLE B2 ***
*************************

use jjm_jebo_21, clear
keep if year == 1932
drop if methopresb1847 == 1

** TABLE B2 COLS 1-3 **

local ourctrls1900 "city1800 port1850_yn traderoute18501890_dist10 slavemarket_strict_dist50 dist2riv_navigable10 soil5 prec_mean alt_mean alt_sd histo_malaria"
capture erase tableB2_cols_1_3.xls
capture erase tableB2_cols_1_3.txt
capture erase tableB2_cols_1_3.tex
foreach O of varlist `ourctrls1900' {
foreach C in 40 {
local lincomset "presby1867 - method1867"
local exogvar "presby1867 method1867"
local basectrls "ldist2coast longitude longitude2 longitude3 longitude4"
acreg `O' `exogvar' `basectrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
proglincom "`lincomset'"
outreg2 `exogvar' `basectrls' using tableB2_cols_1_3.xls, keep(`exogvar') addtext(IV, spheredum, controls, base, conley, `C',presb-metho, `r(coefftxt)', se, `r(setxt)') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local exogvar "east_of_bound"
local basectrls "ldist2coast ldist2segment longitude longitude2 longitude3 longitude4"
acreg `O' `exogvar' `basectrls' if pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' `basectrls' using tableB2_cols_1_3.xls, keep(`exogvar') addtext(IV, westbound, controls, base, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
local exogvar "east_of_bound"
local basectrls "ldist2coast ldist2segment longitude longitude2 longitude3 longitude4"
acreg `O' `exogvar' `basectrls' if sphere1867  == 0 & pres_meth_dhs != ., latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 `exogvar' `basectrls' using tableB2_cols_1_3.xls, keep(`exogvar') addtext(IV, west_nosphere, controls, base, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

** TABLE B2 COL 4 **

* We create the following ethnic group dummies. 
gen ethnicgroups = (ethnic == "FANTI" | ethnic == "GA" | ethnic == "ADANGME" | ethnic == "AKYEM")
gen east_nonfanti = (ethnic != "FANTI")

local ourctrls1900 "city1800 port1850_yn traderoute18501890_dist10 slavemarket_strict_dist50 dist2riv_navigable10 soil5 prec_mean alt_mean alt_sd histo_malaria"
capture erase tableB2_col4.xls
capture erase tableB2_col4.txt
capture erase tableB2_col4.tex
foreach O of varlist `ourctrls1900' {
foreach C in 40 {
local basectrls "ldist2coast ldist2segment longitude longitude2 longitude3 longitude4"
acreg `O' east_nonfanti `basectrls' if pres_meth_dhs != . & ethnicgroups == 1, latitude(latitude) longitude(longitude) dist(`C') spatial
outreg2 east_nonfanti using tableB2_col4.xls, keep(east_nonfanti) addtext(IV, spheredum, controls, base, conley, `C') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel append
}
}

*************************
*** WEB APPX TABLE B6 ***
*************************

use jjm_jebo_21, clear
keep if year == 1932
drop if methopresb1847 == 1
keep if cens_prot_2000 != .
replace methopresb1847 = 0 if methopresb1847 == .

** WEB APPX TABLE B6 **
capture erase tableB6.xls
capture erase tableB6.txt
capture erase tableB6.tex
foreach O in lnltc2000 cens_prot_2000 pres_meth_dhs {
foreach Z in 40 {
* IV: SPHERES *
local basectrls "methopresb1847 ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment presby1867 method1867 `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment presby1867 method1867 using tableB6.xls, keep(ldist2segment presby1867 method1867) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
lincom presby1867 - method1867
* IV: EAST *
local basectrls "methopresb1847 ldist2firstpresb ldist2firstmetho longitude longitude2 longitude3 longitude4"
local ourctrls1900 "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 ln_export_area slavemarket_strict_dist50"
local ourctrls "prec_mean alt_mean alt_sd soil5 histo_malaria port1850_yn ldist2coast nongcc1873 dist2riv_navigable10 traderoute18501890_dist10 exploroute188089_dist10 dist2rail193210 dist2class123_193010 city1800 map08_yn national headchief lupop_1891 lupop_1901 lrpop_1901 lupop_1931 lrpop_1931 ln_export_area slavemarket_strict_dist50 palmoil1900_dist50 kolanut0 rubber1900_dist50 cocoa minet_dist1932_50"
acreg `O' ldist2segment east_of_bound `basectrls' `ourctrls', latitude(latitude) longitude(longitude) dist(`Z') spatial
outreg2 ldist2segment east_of_bound using tableB6.xls, keep(ldist2segment east_of_bound) addtext(test, IV, controls, ours, conley, `Z') br se nocons coefastr bdec(2) sdec(2) rdec(2) noni nolabel
}
}

